package day24;

import java.io.*;
import java.util.Arrays;

//通过io流  复制整个目录
public class Demo5 {
    public static void main(String[] args) throws IOException {
        File files = new File("D:\\a");
        File[] str = files.listFiles();
        System.out.println(Arrays.toString(str));
        if (str != null) {
            for(File f : str){
                find(f);
            }
        }
    }

    static void find(File f) throws IOException {
        if (f.isDirectory()) {
            System.out.println(f.getPath());
            File[] files = f.listFiles();
            System.out.println(Arrays.toString(files));
            if (files != null) {
                for(File f2 : files){
                    find(f2);
                }
            }
        }else {
            if (f.exists()) {
                FileInputStream fis = new FileInputStream(f);

                byte[] bs = new byte[1024];
                int len;
                while ((len = fis.read(bs)) != -1) {

                }
                fis.close();
            } else {
                System.out.println("File not found");
            }
        }
    }
}
